package com.aspire.boc.mms.wmf.cam;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import com.aspire.boc.mms.wmf.model.WmfRole;
/**
 * 管理员信息
 * @author shining
 *
 */
@SuppressWarnings("serial")
public class Admin implements Serializable {
	private String adminName;

	private String creator;

	private String password;

	private String truename;

	private String mobile;

	private String email;

	private String attribute;

	private Date timestamp;

	private int status;

	private String info;

	private int otpstatus;
	
	private String sex;
	
	private Set<Group> groups;
	
	private List<WmfRole> roles ;
	
	// 是否为系统管理员
	private boolean isAdministrator;

	public Set<Group> getGroups() {
		return groups;
	}

	public void setGroups(Set<Group> groups) {
		this.groups = groups;
	}

	public List<WmfRole> getRoles() {
		return roles;
	}

	public void setRoles(List<WmfRole> roles) {
		this.roles = roles;
	}

	public FinePermission permission;
	
	
	public List<String> perspectiveList = new ArrayList<String>();
	
	/**
	 * 是否是系统管理员,跟组管理员为超级管理员
	 * @return
	 */
	public boolean isAdministrator(){

	    return isAdministrator;
	}
	
	public void setAdministrator(boolean isAdministrator) {
	    
	    this.isAdministrator = isAdministrator;
	}

	/**
	 * 是否是一级管理员
	 * 是一级管理员就要赋予一级管理角色而不是通过组对应
	 * @return
	 */
	public boolean isAdminLevel1(){
		boolean f = false;
		if(getAdminGroups().size()>0){
			f = true;
		}
		return f;
	}
	
	public List<Group> getAdminGroups(){
		List<Group> groups = new ArrayList<Group>();
		for(Group group : getGroups()){
			for(String administrator : group.getAdministrator().split(",")){
				if(administrator.equals(getAdminName())){
					groups.add(group);
				}
			}
		}
		return groups;
	}

	/**
	 * ACTIVE: 活跃状态</br> FREEZE: 已冻结
	 */
	public enum Status {
		ACTIVE, FREEZE
	}

	public String getAdminName() {
		return adminName;
	}

	public String getCreator() {
		return creator;
	}

	public String getPassword() {
		return password;
	}

	public String getTruename() {
		return truename;
	}

	public String getMobile() {
		return mobile;
	}

	public String getEmail() {
		return email;
	}

	public String getAttribute() {

		return attribute;
	}

	public Date getTimestamp() {
		return timestamp;
	}

	public int getStatus() {
		return status;
	}

	public String getInfo() {

		return info;
	}

	public void setAdminName(String adminName) {
		this.adminName = adminName;
	}

	public void setCreator(String creator) {
		this.creator = creator;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void setTruename(String truename) {
		this.truename = truename;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public void setAttribute(String attribute) {

		this.attribute = attribute;
	}

	public void setTimestamp(Date timestamp) {
		this.timestamp = timestamp;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public void setInfo(String info) {

		this.info = info;
	}


	public void setPermission(FinePermission permission) {
		this.permission = permission;
	}

	public List<String> getPerspectiveList() {
		return perspectiveList;
	}

	public void setPerspectiveList(List<String> perspectiveList) {
		this.perspectiveList = perspectiveList;
	}

	
	public int getOtpstatus() {
		return otpstatus;
	}

	public void setOtpstatus(int otpstatus) {
		this.otpstatus = otpstatus;
	}

	public static void main(String[] args) {
		Admin a=new Admin();
		System.out.print(a.toString());
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}
}
